#pragma once

#include <string>

#include "Tree.h"
#include "Node.h"
#include "HuffmanCodec.h"
#include "EncodedSymbol.h"

namespace Huffman {

	class VitterHuffmanCodec : public HuffmanCodec
	{
	public:
		VitterHuffmanCodec(std::string inputFile, std::string outputFile);
		~VitterHuffmanCodec(void);

		virtual void encode();
		virtual void decode();

	private:
		void encodeSymbol();
		int decodeSymbol();


		int getSymbolCodeFromNode(Node* node);
		EncodedSymbol* getEncodedSymbolCodeFromNode(Node* node);
		char getSymbolBytes(int symbol);
		void writeSymbolBytes(int bytes);
		void writeSymbol(char symbol);
		void writeEncodedSymbol(EncodedSymbol* symbol);
		char readSymbolBytes();

		void closeStreams();

		Tree* symbolTree;
	};
}
